package com.xcl.service.impl;

import com.xcl.mapper.DeliveryChargeMapper;
import com.xcl.mapper.FinancingMapper;
import com.xcl.mapper.OutsourcingCostMapper;
import com.xcl.pojo.DeliveryCharge;
import com.xcl.service.DeliveryChargeServiceInter;
import com.zzg.entity.Finance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName DeliveryChargeServiceImpl
 * @Description 应付派送费服务层实现类
 * @Author: xiaochaolei
 * @date 2021/7/27 11:03
 * @Version 1. 0
 */
@Service
public class DeliveryChargeServiceImpl implements DeliveryChargeServiceInter {
    @Autowired
    DeliveryChargeMapper deliveryChargeMapper;

    @Autowired
    FinancingMapper financingMapper;
    @Autowired
    OutsourcingCostMapper outsourcingCostMapper;

    @Override
    public List<DeliveryCharge> getAllDeliveryCharge() {
        return deliveryChargeMapper.getAllDeliveryCharge();
    }

    @Override
    public List<DeliveryCharge> getAllDeliveryChargeByLimit(int page, int limit, String delivery_id, String waybill_id, String deliveryDate, String sub_id, String ownerName, String verification) {
        return deliveryChargeMapper.getAllDeliveryChargeByLimit((page-1)*limit,limit, delivery_id,
                waybill_id,
                deliveryDate,
                sub_id,
                ownerName,
                verification);
    }

    @Override
    public int updateVerification(String id) {
        return deliveryChargeMapper.updateVerification(id);
    }

    @Override
    public int  getFinanceById(String id) {
        //根据id查询财务信息
        Finance financeById = deliveryChargeMapper.getFinanceById(id);
        //设置运单状态
        financeById.setOrdertype("已结清");
        //设置修改财务
        financingMapper.updateFinancing(financeById);
        //修改核销状态
        deliveryChargeMapper.updateVerification(id);
        //修改财务详细信息
        return  outsourcingCostMapper.updateCostBreakdown(financeById.getCostbreakdownId());
    }


}
